from apps.disclose.models import Spit
from rest_framework.serializers import ModelSerializer, StringRelatedField


class SpitLIstSerializer(ModelSerializer):
    class Meta:
        model = Spit
        fields = '__all__'


from apps.invite.models import Enterprise, Recruit
from apps.users.models import User


class UserSerializer(ModelSerializer):
    class Meta:
        model = User
        fields = ['id']


class RecruitNUMSerializer(ModelSerializer):
    class Meta:
        model = Recruit
        fields = ['id']


class EnterpriseSerializer(ModelSerializer):
    recruits = RecruitNUMSerializer(read_only=True)

    class Meta:
        model = Enterprise
        fields = ['id', 'name', 'labels', 'logo', 'recruits', 'summary']


class RecruitSerializer(ModelSerializer):
    enterprise = EnterpriseSerializer(read_only=True)

    class Meta:
        model = Recruit
        # fields = '__all__'
        fields = ['id', 'jobname', 'salary', 'condition', 'education', 'type', 'city', 'createtime', 'enterprise',
                  'labels']


class EnterpriseListSerializer(ModelSerializer):
    recruits = RecruitSerializer(read_only=True, many=True)
    users = UserSerializer(read_only=True,many=True)

    class Meta:
        model = Enterprise
        fields = ['id', 'recruits', 'name', 'summary', 'content', 'city', 'address', 'labels', 'coordinate', 'logo',
                  'url', 'visits', 'users']


class EnterpriseVisitSerializer(ModelSerializer):
    class Meta:
        model = Enterprise
        fields = '__all__'
